import rxAjax from '@/assets/js/ajax.js';

//业务实体数据配置 api接口
export const FormEntityDataSettingApi = {};

FormEntityDataSettingApi.baseUrl= '/api-form/form/core/formEntityDataSetting';
FormEntityDataSettingApi.exportUrl= FormEntityDataSettingApi.baseUrl + '/listExport';

//查询列表
FormEntityDataSettingApi.query=function (parameter) {
    var url= FormEntityDataSettingApi.baseUrl + '/query';
    return rxAjax.postJson(url,parameter).then (res => {
        return res.result
    })
}

/**
 * 获取单记录
 * @param pkId
 * @returns {*}
 */
FormEntityDataSettingApi.get =function(pkId) {
    var url= FormEntityDataSettingApi.baseUrl + '/get?pkId=' + pkId;
    return rxAjax.get(url);
}

FormEntityDataSettingApi.getByRoleId=function(roleId,appId){
    var url= FormEntityDataSettingApi.baseUrl + '/getByRoleId?roleId=' + roleId+"&appId="+appId;
    return rxAjax.get(url);
}

FormEntityDataSettingApi.validRole=function(roleId,appId){
    var url= FormEntityDataSettingApi.baseUrl + '/validRole?roleId=' + roleId+"&appId="+appId;
    return rxAjax.get(url);
}

FormEntityDataSettingApi.saveRole=function(parameter){
    var url= FormEntityDataSettingApi.baseUrl + '/saveRole';
    return rxAjax.postJson(url,parameter);
}

//保存数据
FormEntityDataSettingApi.save =function(parameter) {
    var url= FormEntityDataSettingApi.baseUrl + '/save';
    return rxAjax.postJson(url,parameter);
}

//删除数据
FormEntityDataSettingApi.del =function(parameter) {
    var url= FormEntityDataSettingApi.baseUrl + '/del';
    return rxAjax.postUrl(url,parameter);
}

//删除数据
FormEntityDataSettingApi.delByRoleIdAndAppId =function(roleId,appId) {
    var url= FormEntityDataSettingApi.baseUrl + '/delByRoleIdAndAppId?roleId='+roleId+"&appId="+appId;
    return rxAjax.get(url);
}

//批量删除数据
FormEntityDataSettingApi.delByIds =function(ids) {
    var url= FormEntityDataSettingApi.baseUrl + '/delByIds?ids='+ids;
    return rxAjax.get(url);
}

FormEntityDataSettingApi.update =function(parameter) {
    var url= FormEntityDataSettingApi.baseUrl + '/update';
    return rxAjax.postJson(url,parameter);
}

FormEntityDataSettingApi.updExport =function(ids) {
    var url= FormEntityDataSettingApi.baseUrl + '/updExport';
    return rxAjax.postForm(url,{ids:ids});
}

export  default FormEntityDataSettingApi;

